Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hash-object

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-object

A Node.js module that hashes JavaScript objects.

  • 0.1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.6K
decreased by-7.66%
Maintainers
1
Weekly downloads
 
Created
Source

hash-object

Build Status

A Node.js module that hashes JavaScript objects.

Getting Started

Install the module with: npm install hash-object

Documentation

hashObject(obj, [opts])

var hashObject = require('hash-object');
  • obj: the object to be hashed
  • opts: options for the hashing function
    • algorithm: dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha1' (default), 'md5', 'sha256', 'sha512', etc.

Examples

Simple Compare

var hash1 = hashObject({
    a: 'b',
    c: 'd',
    e: 'f'
});
var hash2 = hashObject({
    a: 'b',
    e: 'f',
    c: 'd'
});

// hash1 === hash2

Complex Compare

var hash3 = hashObject({
    a: 'b',
    b: ['c', 'd'],
    c: {
        d: 'e',
        f: {
            g: 'h'
        }
    }
});
var hash4 = hashObject({
    a: 'b',
    c: {
        f: {
            g: 'h'
        },
        d: 'e'
    },
    b: ['c', 'd']
});

// hash3 === hash4

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2014 David Caseria
Licensed under the MIT license.

Keywords

FAQs

Package last updated on 19 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc